<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // prototype 原型对象

        let obj  = {
            name:'张三', //私有属性
            age:15
        }
        console.log(obj);
        console.dir(obj)
        // 找到隐式原型
        // __proto__ 去查找我们所继承的对象直到null
        console.log(obj.__proto__);
        // console.log(obj.__proto__ == obj.prototype);

        let arr1 =new Array(1,2,3)
        let arr2 = new Array(4,5,6)
        console.log(arr1);
        console.log(Array.prototype);
        
        console.log(arr1.__proto__);

        // constructor 存在每一个原型对象上 对应的构造器


        function Cart(color) {
            this.color = color
            // this.setcolor = function (params) {
            //     console.log(this.color,'开始喷漆');
                
            // }
            
        }
        // 把公有属性直接放到原型上
        Cart.prototype.setcolor = function (params) {
            console.log(this.color,'开始喷漆');
        }


        let c1 = new Cart('red')
        let c2 = new Cart('yellow')
        

        console.log(c1);
        console.log(c2);

        c1.setcolor()
        c2.setcolor()
        
        


        
        

    </script>
</body>
</html>